#include<iostream>
#include<list>
using namespace std;
template<typename T>
void removeDuplicates(list<T>& aList)
{
	T curValue;
	list<T>::iterator cur, p;
	cur = aList.begin();
	while (cur != aList.end())
	{
		curValue = *cur;
		p = ++cur;
		while (p != aList.end())
		{
			if (*p == curValue)
			{
				p == cur ? cur = p = aList.erase(p) : p = aList.erase(p);
			}
			else
			{
				p++;
			}
		}
	}
}


//int main()
//{
//	list<int> lt;
//	lt.push_back(1);
//	lt.push_back(1);
//	lt.push_back(2);
//	lt.push_back(3);
//	lt.push_back(4);
//	lt.push_back(5);
//	lt.push_back(5);
//	lt.push_back(6);
//	removeDuplicates(lt);
//	for (auto& e : lt)
//	{
//		cout << e << " ";
//	}
//	cout << endl;
//	return 0;
//}

int main()
{
	int ar[] = { 0,1,2,3,4,5,6,7,8,9 };
	int n = sizeof(ar) / sizeof(int);
	list<int> mylist(ar, ar + n);
	list<int>::iterator pos = find(mylist.begin(), mylist.end(), 5);
	reverse(mylist.begin(), pos);
	reverse(pos, mylist.end());
	list<int>::const_reverse_iterator crit = mylist.crbegin();
	while (crit != mylist.crend())
	{
		cout << *crit << " ";
		++crit;
	}
	cout << endl;
}

